package com;

import com.SPI.api.IOperation;
import com.SPI.impl.MikeOperation;
import com.SPI.spi.WillSPIOperation;

import java.util.Iterator;
import java.util.ServiceLoader;

/**
 * Created by 41579 on 2017/5/27.
 */
public class main {
    public static void main(String[] args) {
        IOperation plus = new MikeOperation();

        IOperation division = new WillSPIOperation();
        System.out.println(plus.operation(5, 3));

        System.out.println(division.operation(9, 3));

        ServiceLoader<IOperation> operations = ServiceLoader.load(IOperation.class);
        Iterator<IOperation> operationIterator = operations.iterator();
        System.out.println("classPath:" + System.getProperty("java.class.path"));
        while (operationIterator.hasNext()) {
            IOperation operation = operationIterator.next();
            System.out.println(operation.operation(6, 3));
        }
    }
}
